<?php

namespace App\Transformers\Statistics;


use App\Models\City;
use App\Models\UserLog;
use League\Fractal\TransformerAbstract;

class UserLogTransformer extends TransformerAbstract
{
    protected $availableIncludes = ['city'];

    public function transform(UserLog $data)
    {
        return [
            'id' => $data->id,
            'user_id'=> $data->user_id ?? '',
            'city_id'=> $data->address_id ?? '',
            'mer_id'=> $data->mer_id ?? '',
            'visitor_num'=> $data->visitor_num ?? '',
            'register_num'=> $data->register_num ?? '',
            'order_num'=> $data->order_num ?? '',
            'recharge_num'=> $data->recharge_num ?? '',
            'list_num'=> $data->list_num ?? '',
            'user_num'=> $data->user_num ?? '',
            'pay_num'=> $data->pay_num ?? '',
            'cumulative_num'=> $data->cumulative_num ?? '',
            'deal_num'=> $data->deal_num ?? '',
            'amount'=> $data->amount ?? '',
            'type' => $data->type?? '',
            'number_num' => $data->number_num ?? '',
            'type_text' => $userTypeEnum[$data->type] ?? '',
            'created_at' => $data->created_at ? $data->created_at->format("Y-m-d H:i:s") : '',
            'updated_at' => $data->updated_at ? $data->updated_at->format("Y-m-d H:i:s") : '',
            'city' => $data->city ?? '',
        ];
    }


    /**
     * 关联地址的信息
     */
//    public function includeCity(UserLog $userLog){
//
//        return $this->item($userLog->city,new City());
//    }
}
